# example from https://github.com/harvester/ipxe-examples/blob/main/general/config-create.yaml

{% if  (settings['harvester_iso_url'] == 'https://releases.rancher.com/harvester/v1.0.3/harvester-v1.0.3-amd64.iso') or (settings['harvester_iso_url'] == 'https://releases.rancher.com/harvester/v1.0.2/harvester-v1.0.2-amd64.iso') or (settings['harvester_iso_url'] == 'https://releases.rancher.com/harvester/v1.0.1/harvester-v1.0.0-amd64.iso') or (settings['harvester_iso_url'] == 'https://releases.rancher.com/harvester/v1.0.0/harvester-v1.0.0-amd64.iso')  %}
token: {{ settings['harvester_config']['token'] }}
os:
  hostname: harvester-node-0
  ssh_authorized_keys:
{% for ssh_key in settings['harvester_config']['ssh_authorized_keys'] %}
    - {{ ssh_key }}
{% endfor %}
  password: {{ settings['harvester_config']['password'] }}
  ntp_servers:
{% for ntp_server in settings['harvester_config']['ntp_servers'] %}
    - {{ ntp_server }}
{% endfor %}
{% if settings['harvester_network_config']['sftp'] %}
  sshd:
    sftp: {{ settings['harvester_network_config']['sftp'] }}
{% endif %}
install:
  mode: create
{% if settings['harvester_network_config']['cluster'][0]['role'] != 'default' %}
  role: {{ settings['harvester_network_config']['cluster'][0]['role'] }}
{% endif %}
  networks:
    harvester-mgmt:
      interfaces:
      - name: {{ settings['harvester_network_config']['cluster'][0]['mgmt_interface'] }}  # The management interface name
      method: dhcp
    bond0:
      interfaces:
      - name: {{ settings['harvester_network_config']['cluster'][0]['vagrant_interface'] }}
      method: dhcp
  device: /dev/vda       # The target disk to install
  iso_url: http://{{ hostvars['pxe_server']['ansible_eth0']['ipv4']['address'] }}/harvester/harvester-amd64.iso
#  tty: ttyS1,115200n8   # For machines without a VGA console
  tty: ttyS0
  vip: {{ settings['harvester_network_config']['vip']['ip'] }}
  vip_mode: {{ settings['harvester_network_config']['vip']['mode'] }}
  vip_hw_addr: {{ settings['harvester_network_config']['vip']['mac'] }}
{% if settings['harvester_network_config']['offline'] %}
systemSettings:
  ui-source: bundled
{% endif %}
{% else %}
scheme_version: 1
token: {{ settings['harvester_config']['token'] }}
os:
  hostname: harvester-node-0
  ssh_authorized_keys:
{% for ssh_key in settings['harvester_config']['ssh_authorized_keys'] %}
    - {{ ssh_key }}
{% endfor %}
  password: {{ settings['harvester_config']['password'] }}
  ntp_servers:
{% for ntp_server in settings['harvester_config']['ntp_servers'] %}
    - {{ ntp_server }}
{% endfor %}
install:
  mode: create
  management_interface:
    interfaces:
    - name: {{ settings['harvester_network_config']['cluster'][0]['mgmt_interface'] }}  # The management interface name
    method: dhcp
  device: /dev/vda       # The target disk to install
  iso_url: http://{{ hostvars['pxe_server']['ansible_eth0']['ipv4']['address'] }}/harvester/harvester-amd64.iso
#  tty: ttyS1,115200n8   # For machines without a VGA console
  tty: ttyS0
  vip: {{ settings['harvester_network_config']['vip']['ip'] }}
  vip_mode: {{ settings['harvester_network_config']['vip']['mode'] }}
  vip_hw_addr: {{ settings['harvester_network_config']['vip']['mac'] }}
{% if settings['harvester_network_config']['offline'] %}
systemSettings:
  ui-source: bundled
{% endif %}
{% endif %}


